package com.xkdx.guangguang.zxing;

import java.util.HashMap;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.xkdx.caipiao.R;
import com.xkdx.guangguang.fragment.BaseFragment;
import com.xkdx.guangguang.module.network.AbsModule;

public class ORFragment extends BaseFragment {
	View view;
	CreateQRImage crt;
	String orStr;
	TextView name, code, time;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		WindowManager wm = (WindowManager) getActivity().getSystemService(
				Context.WINDOW_SERVICE);
		@SuppressWarnings("deprecation")
		int width = wm.getDefaultDisplay().getWidth();

		crt = new CreateQRImage((int) (0.75 * width));
		orStr = getArguments().getString("or");

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.or_image, container, false);
		ImageView im = (ImageView) view.findViewById(R.id.or_iamge);
		Button back = (Button) view.findViewById(R.id.or_image_back);

		try {
			name = (TextView) view.findViewById(R.id.or_name);
			code = (TextView) view.findViewById(R.id.or_code);
			time = (TextView) view.findViewById(R.id.or_time);
			String name = getArguments().getString("name");
			String code = getArguments().getString("code");
			String time = getArguments().getString("time").substring(0, 10);
			this.name.setText(name);
			this.code.setText("兑换码："+code);
			this.time.setText("有效期至："+time);
		} catch (NullPointerException e) {
			e.printStackTrace();
		}

		crt.setImageView(im);
		crt.createQRImage(orStr);
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				getFragmentManager().popBackStack();

			}
		});
		return view;
	}

	@Override
	public void findView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void setOnClick() {
		// TODO Auto-generated method stub

	}

	@Override
	public void showLoading() {
		// TODO Auto-generated method stub

	}

	@Override
	public void showLoaded(HashMap<String, AbsModule> map) {
		// TODO Auto-generated method stub

	}

	@Override
	public void showClick(HashMap<String, AbsModule> map) {
		// TODO Auto-generated method stub

	}

	@Override
	public void showLoadMore(HashMap<String, AbsModule> map) {
		// TODO Auto-generated method stub

	}

}
